
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
  
<!-- Mirrored from werkzeug.palletsprojects.com/en/1.0.x/datastructures/ by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 15 Sep 2020 06:37:09 GMT -->
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=Edge" />
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Data Structures &#8212; Werkzeug Documentation (1.0.x)</title>
    <link rel="stylesheet" href="../_static/werkzeug.css" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    <link rel="stylesheet" type="text/css" href="../../../../assets.readthedocs.org/static/css/badge_only.css" />
    <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script type="text/javascript" src="../_static/jquery.js"></script>
    <script type="text/javascript" src="../_static/underscore.js"></script>
    <script type="text/javascript" src="../_static/doctools.js"></script>
    <script type="text/javascript" src="../_static/language_data.js"></script>
    <script async="async" type="text/javascript" src="../../../../assets.readthedocs.org/static/javascript/readthedocs-doc-embed.js"></script>
    <link rel="shortcut icon" href="../_static/favicon.ico"/>
    <link rel="index" title="Index" href="../genindex/index.html" />
    <link rel="search" title="Search" href="../search/index.html" />
    <link rel="next" title="Utilities" href="../utils/index.html" />
    <link rel="prev" title="HTTP Utilities" href="../http/index.html" />
    <link rel="canonical" href="index.html">
  <script>DOCUMENTATION_OPTIONS.URL_ROOT = '../index.html';</script>
   
  
<!-- RTD Extra Head -->

<!-- 
Always link to the latest version, as canonical.
http://docs.readthedocs.org/en/latest/canonical.html
-->
<link rel="canonical" href="index.html" />

<link rel="stylesheet" href="../../../../assets.readthedocs.org/static/css/readthedocs-doc-embed.css" type="text/css" />

<script type="text/javascript" src="../_static/readthedocs-data.js"></script>

<!-- Add page-specific data, which must exist in the page js, not global -->
<script type="text/javascript">
READTHEDOCS_DATA['page'] = "datastructures"
READTHEDOCS_DATA['source_suffix'] = ".rst"
</script>

<script type="text/javascript" src="../../../../assets.readthedocs.org/static/javascript/readthedocs-analytics.js" async="async"></script>

<!-- end RTD <extrahead> -->
</head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex/index.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex/index.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="../utils/index.html" title="Utilities"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="../http/index.html" title="HTTP Utilities"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="../index.html">Werkzeug Documentation (1.0.x)</a> &#187;</li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="module-werkzeug.datastructures">
<span id="data-structures"></span><h1>Data Structures<a class="headerlink" href="#module-werkzeug.datastructures" title="Permalink to this headline">¶</a></h1>
<p>Werkzeug provides some subclasses of common Python objects to extend them
with additional features.  Some of them are used to make them immutable, others
are used to change some semantics to better work with HTTP.</p>
<div class="section" id="general-purpose">
<h2>General Purpose<a class="headerlink" href="#general-purpose" title="Permalink to this headline">¶</a></h2>
<details class="changelog">
<summary>Changelog</summary><div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.6: </span>The general purpose classes are now pickleable in each protocol as long
as the contained objects are pickleable.  This means that the
<a class="reference internal" href="#werkzeug.datastructures.FileMultiDict" title="werkzeug.datastructures.FileMultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">FileMultiDict</span></code></a> won’t be pickleable as soon as it contains a
file.</p>
</div>
</details><dl class="class">
<dt id="werkzeug.datastructures.TypeConversionDict">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">TypeConversionDict</code><a class="headerlink" href="#werkzeug.datastructures.TypeConversionDict" title="Permalink to this definition">¶</a></dt>
<dd><p>Works like a regular dict but the <a class="reference internal" href="#werkzeug.datastructures.TypeConversionDict.get" title="werkzeug.datastructures.TypeConversionDict.get"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get()</span></code></a> method can perform
type conversions.  <a class="reference internal" href="#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a> and <a class="reference internal" href="#werkzeug.datastructures.CombinedMultiDict" title="werkzeug.datastructures.CombinedMultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">CombinedMultiDict</span></code></a>
are subclasses of this class and provide the same feature.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.5.</span></p>
</div>
</details><dl class="method">
<dt id="werkzeug.datastructures.TypeConversionDict.get">
<code class="descname">get</code><span class="sig-paren">(</span><em>key</em>, <em>default=None</em>, <em>type=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.TypeConversionDict.get" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the default value if the requested data doesn’t exist.
If <cite>type</cite> is provided and is a callable it should convert the value,
return it or raise a <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#ValueError" title="(in Python v3.8)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> if that is not possible.  In
this case the function will return the default as if the value was not
found:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">d</span> <span class="o">=</span> <span class="n">TypeConversionDict</span><span class="p">(</span><span class="n">foo</span><span class="o">=</span><span class="s1">&#39;42&#39;</span><span class="p">,</span> <span class="n">bar</span><span class="o">=</span><span class="s1">&#39;blub&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;foo&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">)</span>
<span class="go">42</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;bar&#39;</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">)</span>
<span class="go">-1</span>
</pre></div>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>key</strong> – The key to be looked up.</li>
<li><strong>default</strong> – The default value to be returned if the key can’t
be looked up.  If not further specified <cite>None</cite> is
returned.</li>
<li><strong>type</strong> – A callable that is used to cast the value in the
<a class="reference internal" href="#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a>.  If a <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#ValueError" title="(in Python v3.8)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> is raised
by this callable the default value is returned.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.ImmutableTypeConversionDict">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">ImmutableTypeConversionDict</code><a class="headerlink" href="#werkzeug.datastructures.ImmutableTypeConversionDict" title="Permalink to this definition">¶</a></dt>
<dd><p>Works like a <a class="reference internal" href="#werkzeug.datastructures.TypeConversionDict" title="werkzeug.datastructures.TypeConversionDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">TypeConversionDict</span></code></a> but does not support
modifications.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.5.</span></p>
</div>
</details><dl class="method">
<dt id="werkzeug.datastructures.ImmutableTypeConversionDict.copy">
<code class="descname">copy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.ImmutableTypeConversionDict.copy" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a shallow mutable copy of this object.  Keep in mind that
the standard library’s <a class="reference internal" href="#werkzeug.datastructures.ImmutableTypeConversionDict.copy" title="werkzeug.datastructures.ImmutableTypeConversionDict.copy"><code class="xref py py-func docutils literal notranslate"><span class="pre">copy()</span></code></a> function is a no-op for this class
like for any other python immutable type (eg: <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">tuple</span></code></a>).</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.MultiDict">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">MultiDict</code><span class="sig-paren">(</span><em>mapping=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict" title="Permalink to this definition">¶</a></dt>
<dd><p>A <a class="reference internal" href="#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a> is a dictionary subclass customized to deal with
multiple values for the same key which is for example used by the parsing
functions in the wrappers.  This is necessary because some HTML form
elements pass multiple values for the same key.</p>
<p><a class="reference internal" href="#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a> implements all standard dictionary methods.
Internally, it saves all values for a key as a list, but the standard dict
access methods will only return the first value for a key. If you want to
gain access to the other values, too, you have to use the <cite>list</cite> methods as
explained below.</p>
<p>Basic Usage:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">d</span> <span class="o">=</span> <span class="n">MultiDict</span><span class="p">([(</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;b&#39;</span><span class="p">),</span> <span class="p">(</span><span class="s1">&#39;a&#39;</span><span class="p">,</span> <span class="s1">&#39;c&#39;</span><span class="p">)])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span>
<span class="go">MultiDict([(&#39;a&#39;, &#39;b&#39;), (&#39;a&#39;, &#39;c&#39;)])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="p">[</span><span class="s1">&#39;a&#39;</span><span class="p">]</span>
<span class="go">&#39;b&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">getlist</span><span class="p">(</span><span class="s1">&#39;a&#39;</span><span class="p">)</span>
<span class="go">[&#39;b&#39;, &#39;c&#39;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="s1">&#39;a&#39;</span> <span class="ow">in</span> <span class="n">d</span>
<span class="go">True</span>
</pre></div>
</div>
<p>It behaves like a normal dict thus all dict functions will only return the
first value when multiple values for one key are found.</p>
<p>From Werkzeug 0.3 onwards, the <cite>KeyError</cite> raised by this class is also a
subclass of the <code class="xref py py-exc docutils literal notranslate"><span class="pre">BadRequest</span></code> HTTP exception and will
render a page for a <code class="docutils literal notranslate"><span class="pre">400</span> <span class="pre">BAD</span> <span class="pre">REQUEST</span></code> if caught in a catch-all for HTTP
exceptions.</p>
<p>A <a class="reference internal" href="#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a> can be constructed from an iterable of
<code class="docutils literal notranslate"><span class="pre">(key,</span> <span class="pre">value)</span></code> tuples, a dict, a <a class="reference internal" href="#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a> or from Werkzeug 0.2
onwards some keyword parameters.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>mapping</strong> – the initial value for the <a class="reference internal" href="#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a>.  Either a
regular dict, an iterable of <code class="docutils literal notranslate"><span class="pre">(key,</span> <span class="pre">value)</span></code> tuples
or <cite>None</cite>.</td>
</tr>
</tbody>
</table>
<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.add">
<code class="descname">add</code><span class="sig-paren">(</span><em>key</em>, <em>value</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict.add" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a new value for the key.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
</details><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>key</strong> – the key for the value.</li>
<li><strong>value</strong> – the value to add.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.clear">
<code class="descname">clear</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; None.  Remove all items from D.<a class="headerlink" href="#werkzeug.datastructures.MultiDict.clear" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.copy">
<code class="descname">copy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict.copy" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a shallow copy of this object.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.deepcopy">
<code class="descname">deepcopy</code><span class="sig-paren">(</span><em>memo=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict.deepcopy" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a deep copy of this object.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.fromkeys">
<code class="descname">fromkeys</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict.fromkeys" title="Permalink to this definition">¶</a></dt>
<dd><p>Create a new dictionary with keys from iterable and values set to value.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.get">
<code class="descname">get</code><span class="sig-paren">(</span><em>key</em>, <em>default=None</em>, <em>type=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict.get" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the default value if the requested data doesn’t exist.
If <cite>type</cite> is provided and is a callable it should convert the value,
return it or raise a <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#ValueError" title="(in Python v3.8)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> if that is not possible.  In
this case the function will return the default as if the value was not
found:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">d</span> <span class="o">=</span> <span class="n">TypeConversionDict</span><span class="p">(</span><span class="n">foo</span><span class="o">=</span><span class="s1">&#39;42&#39;</span><span class="p">,</span> <span class="n">bar</span><span class="o">=</span><span class="s1">&#39;blub&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;foo&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">)</span>
<span class="go">42</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;bar&#39;</span><span class="p">,</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">)</span>
<span class="go">-1</span>
</pre></div>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>key</strong> – The key to be looked up.</li>
<li><strong>default</strong> – The default value to be returned if the key can’t
be looked up.  If not further specified <cite>None</cite> is
returned.</li>
<li><strong>type</strong> – A callable that is used to cast the value in the
<a class="reference internal" href="#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a>.  If a <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#ValueError" title="(in Python v3.8)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> is raised
by this callable the default value is returned.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.getlist">
<code class="descname">getlist</code><span class="sig-paren">(</span><em>key</em>, <em>type=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict.getlist" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the list of items for a given key. If that key is not in the
<cite>MultiDict</cite>, the return value will be an empty list.  Just as <cite>get</cite>
<cite>getlist</cite> accepts a <cite>type</cite> parameter.  All items will be converted
with the callable defined there.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>key</strong> – The key to be looked up.</li>
<li><strong>type</strong> – A callable that is used to cast the value in the
<a class="reference internal" href="#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a>.  If a <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#ValueError" title="(in Python v3.8)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> is raised
by this callable the value will be removed from the list.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">a <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a> of all the values for the key.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.items">
<code class="descname">items</code><span class="sig-paren">(</span><em>multi=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict.items" title="Permalink to this definition">¶</a></dt>
<dd><p>Return an iterator of <code class="docutils literal notranslate"><span class="pre">(key,</span> <span class="pre">value)</span></code> pairs.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>multi</strong> – If set to <cite>True</cite> the iterator returned will have a pair
for each value of each key.  Otherwise it will only
contain pairs for the first value of each key.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.keys">
<code class="descname">keys</code><span class="sig-paren">(</span><span class="sig-paren">)</span> &#x2192; a set-like object providing a view on D's keys<a class="headerlink" href="#werkzeug.datastructures.MultiDict.keys" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.lists">
<code class="descname">lists</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict.lists" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a iterator of <code class="docutils literal notranslate"><span class="pre">(key,</span> <span class="pre">values)</span></code> pairs, where values is the list
of all values associated with the key.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.listvalues">
<code class="descname">listvalues</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict.listvalues" title="Permalink to this definition">¶</a></dt>
<dd><p>Return an iterator of all values associated with a key.  Zipping
<a class="reference internal" href="#werkzeug.datastructures.MultiDict.keys" title="werkzeug.datastructures.MultiDict.keys"><code class="xref py py-meth docutils literal notranslate"><span class="pre">keys()</span></code></a> and this is the same as calling <a class="reference internal" href="#werkzeug.datastructures.MultiDict.lists" title="werkzeug.datastructures.MultiDict.lists"><code class="xref py py-meth docutils literal notranslate"><span class="pre">lists()</span></code></a>:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">d</span> <span class="o">=</span> <span class="n">MultiDict</span><span class="p">({</span><span class="s2">&quot;foo&quot;</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]})</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">zip</span><span class="p">(</span><span class="n">d</span><span class="o">.</span><span class="n">keys</span><span class="p">(),</span> <span class="n">d</span><span class="o">.</span><span class="n">listvalues</span><span class="p">())</span> <span class="o">==</span> <span class="n">d</span><span class="o">.</span><span class="n">lists</span><span class="p">()</span>
<span class="go">True</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.pop">
<code class="descname">pop</code><span class="sig-paren">(</span><em>key</em>, <em>default=no value</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict.pop" title="Permalink to this definition">¶</a></dt>
<dd><p>Pop the first item for a list on the dict.  Afterwards the
key is removed from the dict, so additional values are discarded:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">d</span> <span class="o">=</span> <span class="n">MultiDict</span><span class="p">({</span><span class="s2">&quot;foo&quot;</span><span class="p">:</span> <span class="p">[</span><span class="mi">1</span><span class="p">,</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">]})</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">pop</span><span class="p">(</span><span class="s2">&quot;foo&quot;</span><span class="p">)</span>
<span class="go">1</span>
<span class="gp">&gt;&gt;&gt; </span><span class="s2">&quot;foo&quot;</span> <span class="ow">in</span> <span class="n">d</span>
<span class="go">False</span>
</pre></div>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>key</strong> – the key to pop.</li>
<li><strong>default</strong> – if provided the value to return if the key was
not in the dictionary.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.popitem">
<code class="descname">popitem</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict.popitem" title="Permalink to this definition">¶</a></dt>
<dd><p>Pop an item from the dict.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.popitemlist">
<code class="descname">popitemlist</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict.popitemlist" title="Permalink to this definition">¶</a></dt>
<dd><p>Pop a <code class="docutils literal notranslate"><span class="pre">(key,</span> <span class="pre">list)</span></code> tuple from the dict.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.poplist">
<code class="descname">poplist</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict.poplist" title="Permalink to this definition">¶</a></dt>
<dd><p>Pop the list for a key from the dict.  If the key is not in the dict
an empty list is returned.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.5: </span>If the key does no longer exist a list is returned instead of
raising an error.</p>
</div>
</details></dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.setdefault">
<code class="descname">setdefault</code><span class="sig-paren">(</span><em>key</em>, <em>default=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict.setdefault" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the value for the key if it is in the dict, otherwise it
returns <cite>default</cite> and sets that value for <cite>key</cite>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>key</strong> – The key to be looked up.</li>
<li><strong>default</strong> – The default value to be returned if the key is not
in the dict.  If not further specified it’s <cite>None</cite>.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.setlist">
<code class="descname">setlist</code><span class="sig-paren">(</span><em>key</em>, <em>new_list</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict.setlist" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove the old values for a key and add new ones.  Note that the list
you pass the values in will be shallow-copied before it is inserted in
the dictionary.</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">d</span> <span class="o">=</span> <span class="n">MultiDict</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">setlist</span><span class="p">(</span><span class="s1">&#39;foo&#39;</span><span class="p">,</span> <span class="p">[</span><span class="s1">&#39;1&#39;</span><span class="p">,</span> <span class="s1">&#39;2&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="p">[</span><span class="s1">&#39;foo&#39;</span><span class="p">]</span>
<span class="go">&#39;1&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">getlist</span><span class="p">(</span><span class="s1">&#39;foo&#39;</span><span class="p">)</span>
<span class="go">[&#39;1&#39;, &#39;2&#39;]</span>
</pre></div>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>key</strong> – The key for which the values are set.</li>
<li><strong>new_list</strong> – An iterable with the new values for the key.  Old values
are removed first.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.setlistdefault">
<code class="descname">setlistdefault</code><span class="sig-paren">(</span><em>key</em>, <em>default_list=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict.setlistdefault" title="Permalink to this definition">¶</a></dt>
<dd><p>Like <cite>setdefault</cite> but sets multiple values.  The list returned
is not a copy, but the list that is actually used internally.  This
means that you can put new values into the dict by appending items
to the list:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">d</span> <span class="o">=</span> <span class="n">MultiDict</span><span class="p">({</span><span class="s2">&quot;foo&quot;</span><span class="p">:</span> <span class="mi">1</span><span class="p">})</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">setlistdefault</span><span class="p">(</span><span class="s2">&quot;foo&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">extend</span><span class="p">([</span><span class="mi">2</span><span class="p">,</span> <span class="mi">3</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">getlist</span><span class="p">(</span><span class="s2">&quot;foo&quot;</span><span class="p">)</span>
<span class="go">[1, 2, 3]</span>
</pre></div>
</div>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>key</strong> – The key to be looked up.</li>
<li><strong>default_list</strong> – An iterable of default values.  It is either copied
(in case it was a list) or converted into a list
before returned.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">a <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a></p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.to_dict">
<code class="descname">to_dict</code><span class="sig-paren">(</span><em>flat=True</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict.to_dict" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the contents as regular dict.  If <cite>flat</cite> is <cite>True</cite> the
returned dict will only have the first item present, if <cite>flat</cite> is
<cite>False</cite> all values will be returned as lists.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>flat</strong> – If set to <cite>False</cite> the dict returned will have lists
with all the values in it.  Otherwise it will only
contain the first value for each key.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">a <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></a></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.update">
<code class="descname">update</code><span class="sig-paren">(</span><em>other_dict</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict.update" title="Permalink to this definition">¶</a></dt>
<dd><p>update() extends rather than replaces existing key lists:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">MultiDict</span><span class="p">({</span><span class="s1">&#39;x&#39;</span><span class="p">:</span> <span class="mi">1</span><span class="p">})</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">b</span> <span class="o">=</span> <span class="n">MultiDict</span><span class="p">({</span><span class="s1">&#39;x&#39;</span><span class="p">:</span> <span class="mi">2</span><span class="p">,</span> <span class="s1">&#39;y&#39;</span><span class="p">:</span> <span class="mi">3</span><span class="p">})</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">b</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span>
<span class="go">MultiDict([(&#39;y&#39;, 3), (&#39;x&#39;, 1), (&#39;x&#39;, 2)])</span>
</pre></div>
</div>
<p>If the value list for a key in <code class="docutils literal notranslate"><span class="pre">other_dict</span></code> is empty, no new values
will be added to the dict and the key will not be created:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">x</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;empty_list&#39;</span><span class="p">:</span> <span class="p">[]}</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">y</span> <span class="o">=</span> <span class="n">MultiDict</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">y</span><span class="o">.</span><span class="n">update</span><span class="p">(</span><span class="n">x</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">y</span>
<span class="go">MultiDict([])</span>
</pre></div>
</div>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.MultiDict.values">
<code class="descname">values</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MultiDict.values" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns an iterator of the first value on every key’s value list.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.OrderedMultiDict">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">OrderedMultiDict</code><span class="sig-paren">(</span><em>mapping=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.OrderedMultiDict" title="Permalink to this definition">¶</a></dt>
<dd><p>Works like a regular <a class="reference internal" href="#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a> but preserves the
order of the fields.  To convert the ordered multi dict into a
list you can use the <code class="xref py py-meth docutils literal notranslate"><span class="pre">items()</span></code> method and pass it <code class="docutils literal notranslate"><span class="pre">multi=True</span></code>.</p>
<p>In general an <a class="reference internal" href="#werkzeug.datastructures.OrderedMultiDict" title="werkzeug.datastructures.OrderedMultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">OrderedMultiDict</span></code></a> is an order of magnitude
slower than a <a class="reference internal" href="#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a>.</p>
<div class="admonition-note admonition">
<p class="first admonition-title">note</p>
<p class="last">Due to a limitation in Python you cannot convert an ordered
multi dict into a regular dict by using <code class="docutils literal notranslate"><span class="pre">dict(multidict)</span></code>.
Instead you have to use the <code class="xref py py-meth docutils literal notranslate"><span class="pre">to_dict()</span></code> method, otherwise
the internal bucket objects are exposed.</p>
</div>
</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.ImmutableMultiDict">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">ImmutableMultiDict</code><span class="sig-paren">(</span><em>mapping=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.ImmutableMultiDict" title="Permalink to this definition">¶</a></dt>
<dd><p>An immutable <a class="reference internal" href="#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a>.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.5.</span></p>
</div>
</details><dl class="method">
<dt id="werkzeug.datastructures.ImmutableMultiDict.copy">
<code class="descname">copy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.ImmutableMultiDict.copy" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a shallow mutable copy of this object.  Keep in mind that
the standard library’s <a class="reference internal" href="#werkzeug.datastructures.ImmutableMultiDict.copy" title="werkzeug.datastructures.ImmutableMultiDict.copy"><code class="xref py py-func docutils literal notranslate"><span class="pre">copy()</span></code></a> function is a no-op for this class
like for any other python immutable type (eg: <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">tuple</span></code></a>).</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.ImmutableOrderedMultiDict">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">ImmutableOrderedMultiDict</code><span class="sig-paren">(</span><em>mapping=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.ImmutableOrderedMultiDict" title="Permalink to this definition">¶</a></dt>
<dd><p>An immutable <a class="reference internal" href="#werkzeug.datastructures.OrderedMultiDict" title="werkzeug.datastructures.OrderedMultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">OrderedMultiDict</span></code></a>.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
</details><dl class="method">
<dt id="werkzeug.datastructures.ImmutableOrderedMultiDict.copy">
<code class="descname">copy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.ImmutableOrderedMultiDict.copy" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a shallow mutable copy of this object.  Keep in mind that
the standard library’s <a class="reference internal" href="#werkzeug.datastructures.ImmutableOrderedMultiDict.copy" title="werkzeug.datastructures.ImmutableOrderedMultiDict.copy"><code class="xref py py-func docutils literal notranslate"><span class="pre">copy()</span></code></a> function is a no-op for this class
like for any other python immutable type (eg: <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">tuple</span></code></a>).</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.CombinedMultiDict">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">CombinedMultiDict</code><span class="sig-paren">(</span><em>dicts=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.CombinedMultiDict" title="Permalink to this definition">¶</a></dt>
<dd><p>A read only <a class="reference internal" href="#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a> that you can pass multiple <a class="reference internal" href="#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a>
instances as sequence and it will combine the return values of all wrapped
dicts:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">werkzeug.datastructures</span> <span class="k">import</span> <span class="n">CombinedMultiDict</span><span class="p">,</span> <span class="n">MultiDict</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">post</span> <span class="o">=</span> <span class="n">MultiDict</span><span class="p">([(</span><span class="s1">&#39;foo&#39;</span><span class="p">,</span> <span class="s1">&#39;bar&#39;</span><span class="p">)])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">get</span> <span class="o">=</span> <span class="n">MultiDict</span><span class="p">([(</span><span class="s1">&#39;blub&#39;</span><span class="p">,</span> <span class="s1">&#39;blah&#39;</span><span class="p">)])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">combined</span> <span class="o">=</span> <span class="n">CombinedMultiDict</span><span class="p">([</span><span class="n">get</span><span class="p">,</span> <span class="n">post</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">combined</span><span class="p">[</span><span class="s1">&#39;foo&#39;</span><span class="p">]</span>
<span class="go">&#39;bar&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">combined</span><span class="p">[</span><span class="s1">&#39;blub&#39;</span><span class="p">]</span>
<span class="go">&#39;blah&#39;</span>
</pre></div>
</div>
<p>This works for all read operations and will raise a <cite>TypeError</cite> for
methods that usually change data which isn’t possible.</p>
<p>From Werkzeug 0.3 onwards, the <cite>KeyError</cite> raised by this class is also a
subclass of the <code class="xref py py-exc docutils literal notranslate"><span class="pre">BadRequest</span></code> HTTP exception and will
render a page for a <code class="docutils literal notranslate"><span class="pre">400</span> <span class="pre">BAD</span> <span class="pre">REQUEST</span></code> if caught in a catch-all for HTTP
exceptions.</p>
</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.ImmutableDict">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">ImmutableDict</code><a class="headerlink" href="#werkzeug.datastructures.ImmutableDict" title="Permalink to this definition">¶</a></dt>
<dd><p>An immutable <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></a>.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.5.</span></p>
</div>
</details><dl class="method">
<dt id="werkzeug.datastructures.ImmutableDict.copy">
<code class="descname">copy</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.ImmutableDict.copy" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a shallow mutable copy of this object.  Keep in mind that
the standard library’s <a class="reference internal" href="#werkzeug.datastructures.ImmutableDict.copy" title="werkzeug.datastructures.ImmutableDict.copy"><code class="xref py py-func docutils literal notranslate"><span class="pre">copy()</span></code></a> function is a no-op for this class
like for any other python immutable type (eg: <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#tuple" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">tuple</span></code></a>).</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.ImmutableList">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">ImmutableList</code><a class="headerlink" href="#werkzeug.datastructures.ImmutableList" title="Permalink to this definition">¶</a></dt>
<dd><p>An immutable <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a>.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.5.</span></p>
</div>
</details><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Private:</th><td class="field-body"></td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.FileMultiDict">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">FileMultiDict</code><span class="sig-paren">(</span><em>mapping=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.FileMultiDict" title="Permalink to this definition">¶</a></dt>
<dd><p>A special <a class="reference internal" href="#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a> that has convenience methods to add
files to it.  This is used for <code class="xref py py-class docutils literal notranslate"><span class="pre">EnvironBuilder</span></code> and generally
useful for unittesting.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.5.</span></p>
</div>
</details><dl class="method">
<dt id="werkzeug.datastructures.FileMultiDict.add_file">
<code class="descname">add_file</code><span class="sig-paren">(</span><em>name</em>, <em>file</em>, <em>filename=None</em>, <em>content_type=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.FileMultiDict.add_file" title="Permalink to this definition">¶</a></dt>
<dd><p>Adds a new file to the dict.  <cite>file</cite> can be a file name or
a <code class="xref py py-class docutils literal notranslate"><span class="pre">file</span></code>-like or a <a class="reference internal" href="#werkzeug.datastructures.FileStorage" title="werkzeug.datastructures.FileStorage"><code class="xref py py-class docutils literal notranslate"><span class="pre">FileStorage</span></code></a> object.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>name</strong> – the name of the field.</li>
<li><strong>file</strong> – a filename or <code class="xref py py-class docutils literal notranslate"><span class="pre">file</span></code>-like object</li>
<li><strong>filename</strong> – an optional filename</li>
<li><strong>content_type</strong> – an optional content type</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="http-related">
<span id="http-datastructures"></span><h2>HTTP Related<a class="headerlink" href="#http-related" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="werkzeug.datastructures.Headers">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">Headers</code><span class="sig-paren">(</span><span class="optional">[</span><em>defaults</em><span class="optional">]</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Headers" title="Permalink to this definition">¶</a></dt>
<dd><p>An object that stores some headers.  It has a dict-like interface
but is ordered and can store the same keys multiple times.</p>
<p>This data structure is useful if you want a nicer way to handle WSGI
headers which are stored as tuples in a list.</p>
<p>From Werkzeug 0.3 onwards, the <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#KeyError" title="(in Python v3.8)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">KeyError</span></code></a> raised by this class is
also a subclass of the <code class="xref py py-class docutils literal notranslate"><span class="pre">BadRequest</span></code> HTTP exception
and will render a page for a <code class="docutils literal notranslate"><span class="pre">400</span> <span class="pre">BAD</span> <span class="pre">REQUEST</span></code> if caught in a
catch-all for HTTP exceptions.</p>
<p>Headers is mostly compatible with the Python <a class="reference external" href="https://docs.python.org/3/library/wsgiref.html#wsgiref.headers.Headers" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">wsgiref.headers.Headers</span></code></a>
class, with the exception of <cite>__getitem__</cite>.  <a class="reference external" href="https://docs.python.org/3/library/wsgiref.html#module-wsgiref" title="(in Python v3.8)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">wsgiref</span></code></a> will return
<cite>None</cite> for <code class="docutils literal notranslate"><span class="pre">headers['missing']</span></code>, whereas <a class="reference internal" href="#werkzeug.datastructures.Headers" title="werkzeug.datastructures.Headers"><code class="xref py py-class docutils literal notranslate"><span class="pre">Headers</span></code></a> will raise
a <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#KeyError" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">KeyError</span></code></a>.</p>
<p>To create a new <a class="reference internal" href="#werkzeug.datastructures.Headers" title="werkzeug.datastructures.Headers"><code class="xref py py-class docutils literal notranslate"><span class="pre">Headers</span></code></a> object pass it a list or dict of headers
which are used as default values.  This does not reuse the list passed
to the constructor for internal usage.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>defaults</strong> – The list of default values for the <a class="reference internal" href="#werkzeug.datastructures.Headers" title="werkzeug.datastructures.Headers"><code class="xref py py-class docutils literal notranslate"><span class="pre">Headers</span></code></a>.</td>
</tr>
</tbody>
</table>
<details class="changelog">
<summary>Changelog</summary><div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.9: </span>This data structure now stores unicode values similar to how the
multi dicts do it.  The main difference is that bytes can be set as
well which will automatically be latin1 decoded.</p>
</div>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.9: </span>The <code class="xref py py-meth docutils literal notranslate"><span class="pre">linked()</span></code> function was removed without replacement as it
was an API that does not support the changes to the encoding model.</p>
</div>
</details><dl class="method">
<dt id="werkzeug.datastructures.Headers.add">
<code class="descname">add</code><span class="sig-paren">(</span><em>_key</em>, <em>_value</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Headers.add" title="Permalink to this definition">¶</a></dt>
<dd><p>Add a new header tuple to the list.</p>
<p>Keyword arguments can specify additional parameters for the header
value, with underscores converted to dashes:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">d</span> <span class="o">=</span> <span class="n">Headers</span><span class="p">()</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s1">&#39;Content-Type&#39;</span><span class="p">,</span> <span class="s1">&#39;text/plain&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">add</span><span class="p">(</span><span class="s1">&#39;Content-Disposition&#39;</span><span class="p">,</span> <span class="s1">&#39;attachment&#39;</span><span class="p">,</span> <span class="n">filename</span><span class="o">=</span><span class="s1">&#39;foo.png&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>The keyword argument dumping uses <code class="xref py py-func docutils literal notranslate"><span class="pre">dump_options_header()</span></code>
behind the scenes.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.4.1: </span>keyword arguments were added for <a class="reference external" href="https://docs.python.org/3/library/wsgiref.html#module-wsgiref" title="(in Python v3.8)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">wsgiref</span></code></a> compatibility.</p>
</div>
</details></dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Headers.add_header">
<code class="descname">add_header</code><span class="sig-paren">(</span><em>_key</em>, <em>_value</em>, <em>**_kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Headers.add_header" title="Permalink to this definition">¶</a></dt>
<dd><p>Add a new header tuple to the list.</p>
<p>An alias for <a class="reference internal" href="#werkzeug.datastructures.Headers.add" title="werkzeug.datastructures.Headers.add"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add()</span></code></a> for compatibility with the <a class="reference external" href="https://docs.python.org/3/library/wsgiref.html#module-wsgiref" title="(in Python v3.8)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">wsgiref</span></code></a>
<a class="reference external" href="https://docs.python.org/3/library/wsgiref.html#wsgiref.headers.Headers.add_header" title="(in Python v3.8)"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add_header()</span></code></a> method.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Headers.clear">
<code class="descname">clear</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Headers.clear" title="Permalink to this definition">¶</a></dt>
<dd><p>Clears all headers.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Headers.extend">
<code class="descname">extend</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Headers.extend" title="Permalink to this definition">¶</a></dt>
<dd><p>Extend headers in this object with items from another object
containing header items as well as keyword arguments.</p>
<p>To replace existing keys instead of extending, use
<a class="reference internal" href="#werkzeug.datastructures.Headers.update" title="werkzeug.datastructures.Headers.update"><code class="xref py py-meth docutils literal notranslate"><span class="pre">update()</span></code></a> instead.</p>
<p>If provided, the first argument can be another <a class="reference internal" href="#werkzeug.datastructures.Headers" title="werkzeug.datastructures.Headers"><code class="xref py py-class docutils literal notranslate"><span class="pre">Headers</span></code></a>
object, a <a class="reference internal" href="#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a>, <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></a>, or iterable of
pairs.</p>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 1.0: </span>Support <a class="reference internal" href="#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a>. Allow passing <code class="docutils literal notranslate"><span class="pre">kwargs</span></code>.</p>
</div>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Headers.get">
<code class="descname">get</code><span class="sig-paren">(</span><em>key</em>, <em>default=None</em>, <em>type=None</em>, <em>as_bytes=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Headers.get" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the default value if the requested data doesn’t exist.
If <cite>type</cite> is provided and is a callable it should convert the value,
return it or raise a <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#ValueError" title="(in Python v3.8)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> if that is not possible.  In
this case the function will return the default as if the value was not
found:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">d</span> <span class="o">=</span> <span class="n">Headers</span><span class="p">([(</span><span class="s1">&#39;Content-Length&#39;</span><span class="p">,</span> <span class="s1">&#39;42&#39;</span><span class="p">)])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">d</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="s1">&#39;Content-Length&#39;</span><span class="p">,</span> <span class="nb">type</span><span class="o">=</span><span class="nb">int</span><span class="p">)</span>
<span class="go">42</span>
</pre></div>
</div>
<p>If a headers object is bound you must not add unicode strings
because no encoding takes place.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.9: </span>Added support for <cite>as_bytes</cite>.</p>
</div>
</details><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>key</strong> – The key to be looked up.</li>
<li><strong>default</strong> – The default value to be returned if the key can’t
be looked up.  If not further specified <cite>None</cite> is
returned.</li>
<li><strong>type</strong> – A callable that is used to cast the value in the
<a class="reference internal" href="#werkzeug.datastructures.Headers" title="werkzeug.datastructures.Headers"><code class="xref py py-class docutils literal notranslate"><span class="pre">Headers</span></code></a>.  If a <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#ValueError" title="(in Python v3.8)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> is raised
by this callable the default value is returned.</li>
<li><strong>as_bytes</strong> – return bytes instead of unicode strings.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Headers.get_all">
<code class="descname">get_all</code><span class="sig-paren">(</span><em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Headers.get_all" title="Permalink to this definition">¶</a></dt>
<dd><p>Return a list of all the values for the named field.</p>
<p>This method is compatible with the <a class="reference external" href="https://docs.python.org/3/library/wsgiref.html#module-wsgiref" title="(in Python v3.8)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">wsgiref</span></code></a>
<a class="reference external" href="https://docs.python.org/3/library/wsgiref.html#wsgiref.headers.Headers.get_all" title="(in Python v3.8)"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get_all()</span></code></a> method.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Headers.getlist">
<code class="descname">getlist</code><span class="sig-paren">(</span><em>key</em>, <em>type=None</em>, <em>as_bytes=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Headers.getlist" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the list of items for a given key. If that key is not in the
<a class="reference internal" href="#werkzeug.datastructures.Headers" title="werkzeug.datastructures.Headers"><code class="xref py py-class docutils literal notranslate"><span class="pre">Headers</span></code></a>, the return value will be an empty list.  Just as
<a class="reference internal" href="#werkzeug.datastructures.Headers.get" title="werkzeug.datastructures.Headers.get"><code class="xref py py-meth docutils literal notranslate"><span class="pre">get()</span></code></a> <a class="reference internal" href="#werkzeug.datastructures.Headers.getlist" title="werkzeug.datastructures.Headers.getlist"><code class="xref py py-meth docutils literal notranslate"><span class="pre">getlist()</span></code></a> accepts a <cite>type</cite> parameter.  All items will
be converted with the callable defined there.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.9: </span>Added support for <cite>as_bytes</cite>.</p>
</div>
</details><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first simple">
<li><strong>key</strong> – The key to be looked up.</li>
<li><strong>type</strong> – A callable that is used to cast the value in the
<a class="reference internal" href="#werkzeug.datastructures.Headers" title="werkzeug.datastructures.Headers"><code class="xref py py-class docutils literal notranslate"><span class="pre">Headers</span></code></a>.  If a <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#ValueError" title="(in Python v3.8)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a> is raised
by this callable the value will be removed from the list.</li>
<li><strong>as_bytes</strong> – return bytes instead of unicode strings.</li>
</ul>
</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body"><p class="first last">a <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#list" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">list</span></code></a> of all the values for the key.</p>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Headers.has_key">
<code class="descname">has_key</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Headers.has_key" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if a key is present.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Headers.pop">
<code class="descname">pop</code><span class="sig-paren">(</span><em>key=None</em>, <em>default=no value</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Headers.pop" title="Permalink to this definition">¶</a></dt>
<dd><p>Removes and returns a key or index.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>key</strong> – The key to be popped.  If this is an integer the item at
that position is removed, if it’s a string the value for
that key is.  If the key is omitted or <cite>None</cite> the last
item is removed.</td>
</tr>
<tr class="field-even field"><th class="field-name">Returns:</th><td class="field-body">an item.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Headers.popitem">
<code class="descname">popitem</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Headers.popitem" title="Permalink to this definition">¶</a></dt>
<dd><p>Removes a key or index and returns a (key, value) item.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Headers.remove">
<code class="descname">remove</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Headers.remove" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove a key.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>key</strong> – The key to be removed.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Headers.set">
<code class="descname">set</code><span class="sig-paren">(</span><em>_key</em>, <em>_value</em>, <em>**kw</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Headers.set" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove all header tuples for <cite>key</cite> and add a new one.  The newly
added key either appears at the end of the list if there was no
entry or replaces the first one.</p>
<p>Keyword arguments can specify additional parameters for the header
value, with underscores converted to dashes.  See <a class="reference internal" href="#werkzeug.datastructures.Headers.add" title="werkzeug.datastructures.Headers.add"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add()</span></code></a> for
more information.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.6.1: </span><a class="reference internal" href="#werkzeug.datastructures.Headers.set" title="werkzeug.datastructures.Headers.set"><code class="xref py py-meth docutils literal notranslate"><span class="pre">set()</span></code></a> now accepts the same arguments as <a class="reference internal" href="#werkzeug.datastructures.Headers.add" title="werkzeug.datastructures.Headers.add"><code class="xref py py-meth docutils literal notranslate"><span class="pre">add()</span></code></a>.</p>
</div>
</details><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>key</strong> – The key to be inserted.</li>
<li><strong>value</strong> – The value to be inserted.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Headers.setdefault">
<code class="descname">setdefault</code><span class="sig-paren">(</span><em>key</em>, <em>default</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Headers.setdefault" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the first value for the key if it is in the headers,
otherwise set the header to the value given by <code class="docutils literal notranslate"><span class="pre">default</span></code> and
return that.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>key</strong> – The header key to get.</li>
<li><strong>default</strong> – The value to set for the key if it is not in the
headers.</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Headers.setlist">
<code class="descname">setlist</code><span class="sig-paren">(</span><em>key</em>, <em>values</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Headers.setlist" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove any existing values for a header and add new ones.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>key</strong> – The header key to set.</li>
<li><strong>values</strong> – An iterable of values to set for the key.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="versionadded">
<p><span class="versionmodified">New in version 1.0.</span></p>
</div>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Headers.setlistdefault">
<code class="descname">setlistdefault</code><span class="sig-paren">(</span><em>key</em>, <em>default</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Headers.setlistdefault" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the list of values for the key if it is in the
headers, otherwise set the header to the list of values given
by <code class="docutils literal notranslate"><span class="pre">default</span></code> and return that.</p>
<p>Unlike <a class="reference internal" href="#werkzeug.datastructures.MultiDict.setlistdefault" title="werkzeug.datastructures.MultiDict.setlistdefault"><code class="xref py py-meth docutils literal notranslate"><span class="pre">MultiDict.setlistdefault()</span></code></a>, modifying the returned
list will not affect the headers.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>key</strong> – The header key to get.</li>
<li><strong>default</strong> – An iterable of values to set for the key if it
is not in the headers.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="versionadded">
<p><span class="versionmodified">New in version 1.0.</span></p>
</div>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Headers.to_wsgi_list">
<code class="descname">to_wsgi_list</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Headers.to_wsgi_list" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert the headers into a list suitable for WSGI.</p>
<p>The values are byte strings in Python 2 converted to latin1 and unicode
strings in Python 3 for the WSGI server to encode.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Returns:</th><td class="field-body">list</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Headers.update">
<code class="descname">update</code><span class="sig-paren">(</span><em>*args</em>, <em>**kwargs</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Headers.update" title="Permalink to this definition">¶</a></dt>
<dd><p>Replace headers in this object with items from another
headers object and keyword arguments.</p>
<p>To extend existing keys instead of replacing, use <a class="reference internal" href="#werkzeug.datastructures.Headers.extend" title="werkzeug.datastructures.Headers.extend"><code class="xref py py-meth docutils literal notranslate"><span class="pre">extend()</span></code></a>
instead.</p>
<p>If provided, the first argument can be another <a class="reference internal" href="#werkzeug.datastructures.Headers" title="werkzeug.datastructures.Headers"><code class="xref py py-class docutils literal notranslate"><span class="pre">Headers</span></code></a>
object, a <a class="reference internal" href="#werkzeug.datastructures.MultiDict" title="werkzeug.datastructures.MultiDict"><code class="xref py py-class docutils literal notranslate"><span class="pre">MultiDict</span></code></a>, <a class="reference external" href="https://docs.python.org/3/library/stdtypes.html#dict" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">dict</span></code></a>, or iterable of
pairs.</p>
<div class="versionadded">
<p><span class="versionmodified">New in version 1.0.</span></p>
</div>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.EnvironHeaders">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">EnvironHeaders</code><span class="sig-paren">(</span><em>environ</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.EnvironHeaders" title="Permalink to this definition">¶</a></dt>
<dd><p>Read only version of the headers from a WSGI environment.  This
provides the same interface as <cite>Headers</cite> and is constructed from
a WSGI environment.</p>
<p>From Werkzeug 0.3 onwards, the <cite>KeyError</cite> raised by this class is also a
subclass of the <code class="xref py py-exc docutils literal notranslate"><span class="pre">BadRequest</span></code> HTTP exception and will
render a page for a <code class="docutils literal notranslate"><span class="pre">400</span> <span class="pre">BAD</span> <span class="pre">REQUEST</span></code> if caught in a catch-all for
HTTP exceptions.</p>
</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.HeaderSet">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">HeaderSet</code><span class="sig-paren">(</span><em>headers=None</em>, <em>on_update=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.HeaderSet" title="Permalink to this definition">¶</a></dt>
<dd><p>Similar to the <a class="reference internal" href="#werkzeug.datastructures.ETags" title="werkzeug.datastructures.ETags"><code class="xref py py-class docutils literal notranslate"><span class="pre">ETags</span></code></a> class this implements a set-like structure.
Unlike <a class="reference internal" href="#werkzeug.datastructures.ETags" title="werkzeug.datastructures.ETags"><code class="xref py py-class docutils literal notranslate"><span class="pre">ETags</span></code></a> this is case insensitive and used for vary, allow, and
content-language headers.</p>
<p>If not constructed using the <code class="xref py py-func docutils literal notranslate"><span class="pre">parse_set_header()</span></code> function the
instantiation works like this:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span> <span class="o">=</span> <span class="n">HeaderSet</span><span class="p">([</span><span class="s1">&#39;foo&#39;</span><span class="p">,</span> <span class="s1">&#39;bar&#39;</span><span class="p">,</span> <span class="s1">&#39;baz&#39;</span><span class="p">])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">hs</span>
<span class="go">HeaderSet([&#39;foo&#39;, &#39;bar&#39;, &#39;baz&#39;])</span>
</pre></div>
</div>
<dl class="method">
<dt id="werkzeug.datastructures.HeaderSet.add">
<code class="descname">add</code><span class="sig-paren">(</span><em>header</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.HeaderSet.add" title="Permalink to this definition">¶</a></dt>
<dd><p>Add a new header to the set.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.HeaderSet.as_set">
<code class="descname">as_set</code><span class="sig-paren">(</span><em>preserve_casing=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.HeaderSet.as_set" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the set as real python set type.  When calling this, all
the items are converted to lowercase and the ordering is lost.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>preserve_casing</strong> – if set to <cite>True</cite> the items in the set returned
will have the original case like in the
<a class="reference internal" href="#werkzeug.datastructures.HeaderSet" title="werkzeug.datastructures.HeaderSet"><code class="xref py py-class docutils literal notranslate"><span class="pre">HeaderSet</span></code></a>, otherwise they will
be lowercase.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.HeaderSet.clear">
<code class="descname">clear</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.HeaderSet.clear" title="Permalink to this definition">¶</a></dt>
<dd><p>Clear the set.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.HeaderSet.discard">
<code class="descname">discard</code><span class="sig-paren">(</span><em>header</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.HeaderSet.discard" title="Permalink to this definition">¶</a></dt>
<dd><p>Like <a class="reference internal" href="#werkzeug.datastructures.HeaderSet.remove" title="werkzeug.datastructures.HeaderSet.remove"><code class="xref py py-meth docutils literal notranslate"><span class="pre">remove()</span></code></a> but ignores errors.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>header</strong> – the header to be discarded.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.HeaderSet.find">
<code class="descname">find</code><span class="sig-paren">(</span><em>header</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.HeaderSet.find" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the index of the header in the set or return -1 if not found.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>header</strong> – the header to be looked up.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.HeaderSet.index">
<code class="descname">index</code><span class="sig-paren">(</span><em>header</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.HeaderSet.index" title="Permalink to this definition">¶</a></dt>
<dd><p>Return the index of the header in the set or raise an
<a class="reference external" href="https://docs.python.org/3/library/exceptions.html#IndexError" title="(in Python v3.8)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">IndexError</span></code></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>header</strong> – the header to be looked up.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.HeaderSet.remove">
<code class="descname">remove</code><span class="sig-paren">(</span><em>header</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.HeaderSet.remove" title="Permalink to this definition">¶</a></dt>
<dd><p>Remove a header from the set.  This raises an <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#KeyError" title="(in Python v3.8)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">KeyError</span></code></a> if the
header is not in the set.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.5: </span>In older versions a <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#IndexError" title="(in Python v3.8)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">IndexError</span></code></a> was raised instead of a
<a class="reference external" href="https://docs.python.org/3/library/exceptions.html#KeyError" title="(in Python v3.8)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">KeyError</span></code></a> if the object was missing.</p>
</div>
</details><table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>header</strong> – the header to be removed.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.HeaderSet.to_header">
<code class="descname">to_header</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.HeaderSet.to_header" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert the header set into an HTTP header string.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.HeaderSet.update">
<code class="descname">update</code><span class="sig-paren">(</span><em>iterable</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.HeaderSet.update" title="Permalink to this definition">¶</a></dt>
<dd><p>Add all the headers from the iterable to the set.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>iterable</strong> – updates the set with the items from the iterable.</td>
</tr>
</tbody>
</table>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.Accept">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">Accept</code><span class="sig-paren">(</span><em>values=()</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Accept" title="Permalink to this definition">¶</a></dt>
<dd><p>An <a class="reference internal" href="#werkzeug.datastructures.Accept" title="werkzeug.datastructures.Accept"><code class="xref py py-class docutils literal notranslate"><span class="pre">Accept</span></code></a> object is just a list subclass for lists of
<code class="docutils literal notranslate"><span class="pre">(value,</span> <span class="pre">quality)</span></code> tuples.  It is automatically sorted by specificity
and quality.</p>
<p>All <a class="reference internal" href="#werkzeug.datastructures.Accept" title="werkzeug.datastructures.Accept"><code class="xref py py-class docutils literal notranslate"><span class="pre">Accept</span></code></a> objects work similar to a list but provide extra
functionality for working with the data.  Containment checks are
normalized to the rules of that header:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="n">a</span> <span class="o">=</span> <span class="n">CharsetAccept</span><span class="p">([(</span><span class="s1">&#39;ISO-8859-1&#39;</span><span class="p">,</span> <span class="mi">1</span><span class="p">),</span> <span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">,</span> <span class="mf">0.7</span><span class="p">)])</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="o">.</span><span class="n">best</span>
<span class="go">&#39;ISO-8859-1&#39;</span>
<span class="gp">&gt;&gt;&gt; </span><span class="s1">&#39;iso-8859-1&#39;</span> <span class="ow">in</span> <span class="n">a</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="s1">&#39;UTF8&#39;</span> <span class="ow">in</span> <span class="n">a</span>
<span class="go">True</span>
<span class="gp">&gt;&gt;&gt; </span><span class="s1">&#39;utf7&#39;</span> <span class="ow">in</span> <span class="n">a</span>
<span class="go">False</span>
</pre></div>
</div>
<p>To get the quality for an item you can use normal item lookup:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span> <span class="n">a</span><span class="p">[</span><span class="s1">&#39;utf-8&#39;</span><span class="p">]</span>
<span class="go">0.7</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">a</span><span class="p">[</span><span class="s1">&#39;utf7&#39;</span><span class="p">]</span>
<span class="go">0</span>
</pre></div>
</div>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 1.0.0: </span><a class="reference internal" href="#werkzeug.datastructures.Accept" title="werkzeug.datastructures.Accept"><code class="xref py py-class docutils literal notranslate"><span class="pre">Accept</span></code></a> internal values are no longer ordered
alphabetically for equal quality tags. Instead the initial
order is preserved.</p>
</div>
<details class="changelog">
<summary>Changelog</summary><div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.5: </span><a class="reference internal" href="#werkzeug.datastructures.Accept" title="werkzeug.datastructures.Accept"><code class="xref py py-class docutils literal notranslate"><span class="pre">Accept</span></code></a> objects are forced immutable now.</p>
</div>
</details><dl class="attribute">
<dt id="werkzeug.datastructures.Accept.best">
<code class="descname">best</code><a class="headerlink" href="#werkzeug.datastructures.Accept.best" title="Permalink to this definition">¶</a></dt>
<dd><p>The best match as value.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Accept.best_match">
<code class="descname">best_match</code><span class="sig-paren">(</span><em>matches</em>, <em>default=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Accept.best_match" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the best match from a list of possible matches based
on the specificity and quality of the client. If two items have the
same quality and specificity, the one is returned that comes first.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>matches</strong> – a list of matches to check for</li>
<li><strong>default</strong> – the value that is returned if none match</li>
</ul>
</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Accept.find">
<code class="descname">find</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Accept.find" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the position of an entry or return -1.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>key</strong> – The key to be looked up.</td>
</tr>
</tbody>
</table>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Accept.index">
<code class="descname">index</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Accept.index" title="Permalink to this definition">¶</a></dt>
<dd><p>Get the position of an entry or raise <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#ValueError" title="(in Python v3.8)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">ValueError</span></code></a>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><strong>key</strong> – The key to be looked up.</td>
</tr>
</tbody>
</table>
<details class="changelog">
<summary>Changelog</summary><div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.5: </span>This used to raise <a class="reference external" href="https://docs.python.org/3/library/exceptions.html#IndexError" title="(in Python v3.8)"><code class="xref py py-exc docutils literal notranslate"><span class="pre">IndexError</span></code></a>, which was inconsistent
with the list API.</p>
</div>
</details></dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Accept.quality">
<code class="descname">quality</code><span class="sig-paren">(</span><em>key</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Accept.quality" title="Permalink to this definition">¶</a></dt>
<dd><p>Returns the quality of the key.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.6: </span>In previous versions you had to use the item-lookup syntax
(eg: <code class="docutils literal notranslate"><span class="pre">obj[key]</span></code> instead of <code class="docutils literal notranslate"><span class="pre">obj.quality(key)</span></code>)</p>
</div>
</details></dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Accept.to_header">
<code class="descname">to_header</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Accept.to_header" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert the header set into an HTTP header string.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Accept.values">
<code class="descname">values</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Accept.values" title="Permalink to this definition">¶</a></dt>
<dd><p>Iterate over all values.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.MIMEAccept">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">MIMEAccept</code><span class="sig-paren">(</span><em>values=()</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.MIMEAccept" title="Permalink to this definition">¶</a></dt>
<dd><p>Like <a class="reference internal" href="#werkzeug.datastructures.Accept" title="werkzeug.datastructures.Accept"><code class="xref py py-class docutils literal notranslate"><span class="pre">Accept</span></code></a> but with special methods and behavior for
mimetypes.</p>
<dl class="attribute">
<dt id="werkzeug.datastructures.MIMEAccept.accept_html">
<code class="descname">accept_html</code><a class="headerlink" href="#werkzeug.datastructures.MIMEAccept.accept_html" title="Permalink to this definition">¶</a></dt>
<dd><p>True if this object accepts HTML.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.MIMEAccept.accept_json">
<code class="descname">accept_json</code><a class="headerlink" href="#werkzeug.datastructures.MIMEAccept.accept_json" title="Permalink to this definition">¶</a></dt>
<dd><p>True if this object accepts JSON.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.MIMEAccept.accept_xhtml">
<code class="descname">accept_xhtml</code><a class="headerlink" href="#werkzeug.datastructures.MIMEAccept.accept_xhtml" title="Permalink to this definition">¶</a></dt>
<dd><p>True if this object accepts XHTML.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.CharsetAccept">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">CharsetAccept</code><span class="sig-paren">(</span><em>values=()</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.CharsetAccept" title="Permalink to this definition">¶</a></dt>
<dd><p>Like <a class="reference internal" href="#werkzeug.datastructures.Accept" title="werkzeug.datastructures.Accept"><code class="xref py py-class docutils literal notranslate"><span class="pre">Accept</span></code></a> but with normalization for charsets.</p>
</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.LanguageAccept">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">LanguageAccept</code><span class="sig-paren">(</span><em>values=()</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.LanguageAccept" title="Permalink to this definition">¶</a></dt>
<dd><p>Like <a class="reference internal" href="#werkzeug.datastructures.Accept" title="werkzeug.datastructures.Accept"><code class="xref py py-class docutils literal notranslate"><span class="pre">Accept</span></code></a> but with normalization for language tags.</p>
</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.RequestCacheControl">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">RequestCacheControl</code><span class="sig-paren">(</span><em>values=()</em>, <em>on_update=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.RequestCacheControl" title="Permalink to this definition">¶</a></dt>
<dd><p>A cache control for requests.  This is immutable and gives access
to all the request-relevant cache control headers.</p>
<p>To get a header of the <a class="reference internal" href="#werkzeug.datastructures.RequestCacheControl" title="werkzeug.datastructures.RequestCacheControl"><code class="xref py py-class docutils literal notranslate"><span class="pre">RequestCacheControl</span></code></a> object again you can
convert the object into a string or call the <code class="xref py py-meth docutils literal notranslate"><span class="pre">to_header()</span></code> method.  If
you plan to subclass it and add your own items have a look at the sourcecode
for that class.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.5: </span>In previous versions a <cite>CacheControl</cite> class existed that was used
both for request and response.</p>
</div>
</details><dl class="attribute">
<dt id="werkzeug.datastructures.RequestCacheControl.no_cache">
<code class="descname">no_cache</code><a class="headerlink" href="#werkzeug.datastructures.RequestCacheControl.no_cache" title="Permalink to this definition">¶</a></dt>
<dd><p>accessor for ‘no-cache’</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.RequestCacheControl.no_store">
<code class="descname">no_store</code><a class="headerlink" href="#werkzeug.datastructures.RequestCacheControl.no_store" title="Permalink to this definition">¶</a></dt>
<dd><p>accessor for ‘no-store’</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.RequestCacheControl.max_age">
<code class="descname">max_age</code><a class="headerlink" href="#werkzeug.datastructures.RequestCacheControl.max_age" title="Permalink to this definition">¶</a></dt>
<dd><p>accessor for ‘max-age’</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.RequestCacheControl.no_transform">
<code class="descname">no_transform</code><a class="headerlink" href="#werkzeug.datastructures.RequestCacheControl.no_transform" title="Permalink to this definition">¶</a></dt>
<dd><p>accessor for ‘no-transform’</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.RequestCacheControl.max_stale">
<code class="descname">max_stale</code><a class="headerlink" href="#werkzeug.datastructures.RequestCacheControl.max_stale" title="Permalink to this definition">¶</a></dt>
<dd><p>accessor for ‘max-stale’</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.RequestCacheControl.min_fresh">
<code class="descname">min_fresh</code><a class="headerlink" href="#werkzeug.datastructures.RequestCacheControl.min_fresh" title="Permalink to this definition">¶</a></dt>
<dd><p>accessor for ‘min-fresh’</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.RequestCacheControl.only_if_cached">
<code class="descname">only_if_cached</code><a class="headerlink" href="#werkzeug.datastructures.RequestCacheControl.only_if_cached" title="Permalink to this definition">¶</a></dt>
<dd><p>accessor for ‘only-if-cached’</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.ResponseCacheControl">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">ResponseCacheControl</code><span class="sig-paren">(</span><em>values=()</em>, <em>on_update=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.ResponseCacheControl" title="Permalink to this definition">¶</a></dt>
<dd><p>A cache control for responses.  Unlike <a class="reference internal" href="#werkzeug.datastructures.RequestCacheControl" title="werkzeug.datastructures.RequestCacheControl"><code class="xref py py-class docutils literal notranslate"><span class="pre">RequestCacheControl</span></code></a>
this is mutable and gives access to response-relevant cache control
headers.</p>
<p>To get a header of the <a class="reference internal" href="#werkzeug.datastructures.ResponseCacheControl" title="werkzeug.datastructures.ResponseCacheControl"><code class="xref py py-class docutils literal notranslate"><span class="pre">ResponseCacheControl</span></code></a> object again you can
convert the object into a string or call the <code class="xref py py-meth docutils literal notranslate"><span class="pre">to_header()</span></code> method.  If
you plan to subclass it and add your own items have a look at the sourcecode
for that class.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.5: </span>In previous versions a <cite>CacheControl</cite> class existed that was used
both for request and response.</p>
</div>
</details><dl class="attribute">
<dt id="werkzeug.datastructures.ResponseCacheControl.no_cache">
<code class="descname">no_cache</code><a class="headerlink" href="#werkzeug.datastructures.ResponseCacheControl.no_cache" title="Permalink to this definition">¶</a></dt>
<dd><p>accessor for ‘no-cache’</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.ResponseCacheControl.no_store">
<code class="descname">no_store</code><a class="headerlink" href="#werkzeug.datastructures.ResponseCacheControl.no_store" title="Permalink to this definition">¶</a></dt>
<dd><p>accessor for ‘no-store’</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.ResponseCacheControl.max_age">
<code class="descname">max_age</code><a class="headerlink" href="#werkzeug.datastructures.ResponseCacheControl.max_age" title="Permalink to this definition">¶</a></dt>
<dd><p>accessor for ‘max-age’</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.ResponseCacheControl.no_transform">
<code class="descname">no_transform</code><a class="headerlink" href="#werkzeug.datastructures.ResponseCacheControl.no_transform" title="Permalink to this definition">¶</a></dt>
<dd><p>accessor for ‘no-transform’</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.ResponseCacheControl.immutable">
<code class="descname">immutable</code><a class="headerlink" href="#werkzeug.datastructures.ResponseCacheControl.immutable" title="Permalink to this definition">¶</a></dt>
<dd><p>accessor for ‘immutable’</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.ResponseCacheControl.must_revalidate">
<code class="descname">must_revalidate</code><a class="headerlink" href="#werkzeug.datastructures.ResponseCacheControl.must_revalidate" title="Permalink to this definition">¶</a></dt>
<dd><p>accessor for ‘must-revalidate’</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.ResponseCacheControl.private">
<code class="descname">private</code><a class="headerlink" href="#werkzeug.datastructures.ResponseCacheControl.private" title="Permalink to this definition">¶</a></dt>
<dd><p>accessor for ‘private’</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.ResponseCacheControl.proxy_revalidate">
<code class="descname">proxy_revalidate</code><a class="headerlink" href="#werkzeug.datastructures.ResponseCacheControl.proxy_revalidate" title="Permalink to this definition">¶</a></dt>
<dd><p>accessor for ‘proxy-revalidate’</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.ResponseCacheControl.public">
<code class="descname">public</code><a class="headerlink" href="#werkzeug.datastructures.ResponseCacheControl.public" title="Permalink to this definition">¶</a></dt>
<dd><p>accessor for ‘public’</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.ResponseCacheControl.s_maxage">
<code class="descname">s_maxage</code><a class="headerlink" href="#werkzeug.datastructures.ResponseCacheControl.s_maxage" title="Permalink to this definition">¶</a></dt>
<dd><p>accessor for ‘s-maxage’</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.ETags">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">ETags</code><span class="sig-paren">(</span><em>strong_etags=None</em>, <em>weak_etags=None</em>, <em>star_tag=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.ETags" title="Permalink to this definition">¶</a></dt>
<dd><p>A set that can be used to check if one etag is present in a collection
of etags.</p>
<dl class="method">
<dt id="werkzeug.datastructures.ETags.as_set">
<code class="descname">as_set</code><span class="sig-paren">(</span><em>include_weak=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.ETags.as_set" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert the <cite>ETags</cite> object into a python set.  Per default all the
weak etags are not part of this set.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.ETags.contains">
<code class="descname">contains</code><span class="sig-paren">(</span><em>etag</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.ETags.contains" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if an etag is part of the set ignoring weak tags.
It is also possible to use the <code class="docutils literal notranslate"><span class="pre">in</span></code> operator.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.ETags.contains_raw">
<code class="descname">contains_raw</code><span class="sig-paren">(</span><em>etag</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.ETags.contains_raw" title="Permalink to this definition">¶</a></dt>
<dd><p>When passed a quoted tag it will check if this tag is part of the
set.  If the tag is weak it is checked against weak and strong tags,
otherwise strong only.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.ETags.contains_weak">
<code class="descname">contains_weak</code><span class="sig-paren">(</span><em>etag</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.ETags.contains_weak" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if an etag is part of the set including weak and strong tags.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.ETags.is_strong">
<code class="descname">is_strong</code><span class="sig-paren">(</span><em>etag</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.ETags.is_strong" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if an etag is strong.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.ETags.is_weak">
<code class="descname">is_weak</code><span class="sig-paren">(</span><em>etag</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.ETags.is_weak" title="Permalink to this definition">¶</a></dt>
<dd><p>Check if an etag is weak.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.ETags.to_header">
<code class="descname">to_header</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.ETags.to_header" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert the etags set into a HTTP header string.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.Authorization">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">Authorization</code><span class="sig-paren">(</span><em>auth_type</em>, <em>data=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Authorization" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents an <cite>Authorization</cite> header sent by the client.  You should
not create this kind of object yourself but use it when it’s returned by
the <cite>parse_authorization_header</cite> function.</p>
<p>This object is a dict subclass and can be altered by setting dict items
but it should be considered immutable as it’s returned by the client and
not meant for modifications.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.5: </span>This object became immutable.</p>
</div>
</details><dl class="attribute">
<dt id="werkzeug.datastructures.Authorization.cnonce">
<code class="descname">cnonce</code><a class="headerlink" href="#werkzeug.datastructures.Authorization.cnonce" title="Permalink to this definition">¶</a></dt>
<dd><p>If the server sent a qop-header in the <code class="docutils literal notranslate"><span class="pre">WWW-Authenticate</span></code>
header, the client has to provide this value for HTTP digest auth.
See the RFC for more details.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.Authorization.nc">
<code class="descname">nc</code><a class="headerlink" href="#werkzeug.datastructures.Authorization.nc" title="Permalink to this definition">¶</a></dt>
<dd><p>The nonce count value transmitted by clients if a qop-header is
also transmitted.  HTTP digest auth only.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.Authorization.nonce">
<code class="descname">nonce</code><a class="headerlink" href="#werkzeug.datastructures.Authorization.nonce" title="Permalink to this definition">¶</a></dt>
<dd><p>The nonce the server sent for digest auth, sent back by the client.
A nonce should be unique for every 401 response for HTTP digest auth.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.Authorization.opaque">
<code class="descname">opaque</code><a class="headerlink" href="#werkzeug.datastructures.Authorization.opaque" title="Permalink to this definition">¶</a></dt>
<dd><p>The opaque header from the server returned unchanged by the client.
It is recommended that this string be base64 or hexadecimal data.
Digest auth only.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.Authorization.password">
<code class="descname">password</code><a class="headerlink" href="#werkzeug.datastructures.Authorization.password" title="Permalink to this definition">¶</a></dt>
<dd><p>When the authentication type is basic this is the password
transmitted by the client, else <cite>None</cite>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.Authorization.qop">
<code class="descname">qop</code><a class="headerlink" href="#werkzeug.datastructures.Authorization.qop" title="Permalink to this definition">¶</a></dt>
<dd><p>Indicates what “quality of protection” the client has applied to
the message for HTTP digest auth. Note that this is a single token,
not a quoted list of alternatives as in WWW-Authenticate.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.Authorization.realm">
<code class="descname">realm</code><a class="headerlink" href="#werkzeug.datastructures.Authorization.realm" title="Permalink to this definition">¶</a></dt>
<dd><p>This is the server realm sent back for HTTP digest auth.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.Authorization.response">
<code class="descname">response</code><a class="headerlink" href="#werkzeug.datastructures.Authorization.response" title="Permalink to this definition">¶</a></dt>
<dd><p>A string of 32 hex digits computed as defined in RFC 2617, which
proves that the user knows a password.  Digest auth only.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.Authorization.uri">
<code class="descname">uri</code><a class="headerlink" href="#werkzeug.datastructures.Authorization.uri" title="Permalink to this definition">¶</a></dt>
<dd><p>The URI from Request-URI of the Request-Line; duplicated because
proxies are allowed to change the Request-Line in transit.  HTTP
digest auth only.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.Authorization.username">
<code class="descname">username</code><a class="headerlink" href="#werkzeug.datastructures.Authorization.username" title="Permalink to this definition">¶</a></dt>
<dd><p>The username transmitted.  This is set for both basic and digest
auth all the time.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.WWWAuthenticate">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">WWWAuthenticate</code><span class="sig-paren">(</span><em>auth_type=None</em>, <em>values=None</em>, <em>on_update=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.WWWAuthenticate" title="Permalink to this definition">¶</a></dt>
<dd><p>Provides simple access to <cite>WWW-Authenticate</cite> headers.</p>
<dl class="attribute">
<dt id="werkzeug.datastructures.WWWAuthenticate.algorithm">
<code class="descname">algorithm</code><a class="headerlink" href="#werkzeug.datastructures.WWWAuthenticate.algorithm" title="Permalink to this definition">¶</a></dt>
<dd><p>A string indicating a pair of algorithms used to produce
the digest and a checksum. If this is not present it is assumed
to be “MD5”. If the algorithm is not understood, the challenge
should be ignored (and a different one used, if there is more
than one).</p>
</dd></dl>

<dl class="staticmethod">
<dt id="werkzeug.datastructures.WWWAuthenticate.auth_property">
<em class="property">static </em><code class="descname">auth_property</code><span class="sig-paren">(</span><em>name</em>, <em>doc=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.WWWAuthenticate.auth_property" title="Permalink to this definition">¶</a></dt>
<dd><p>A static helper function for subclasses to add extra authentication
system properties onto a class:</p>
<div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="k">class</span> <span class="nc">FooAuthenticate</span><span class="p">(</span><span class="n">WWWAuthenticate</span><span class="p">):</span>
    <span class="n">special_realm</span> <span class="o">=</span> <span class="n">auth_property</span><span class="p">(</span><span class="s1">&#39;special_realm&#39;</span><span class="p">)</span>
</pre></div>
</div>
<p>For more information have a look at the sourcecode to see how the
regular properties (<a class="reference internal" href="#werkzeug.datastructures.WWWAuthenticate.realm" title="werkzeug.datastructures.WWWAuthenticate.realm"><code class="xref py py-attr docutils literal notranslate"><span class="pre">realm</span></code></a> etc.) are implemented.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.WWWAuthenticate.domain">
<code class="descname">domain</code><a class="headerlink" href="#werkzeug.datastructures.WWWAuthenticate.domain" title="Permalink to this definition">¶</a></dt>
<dd><p>A list of URIs that define the protection space. If a URI
is an absolute path, it is relative to the canonical root URL of
the server being accessed.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.WWWAuthenticate.nonce">
<code class="descname">nonce</code><a class="headerlink" href="#werkzeug.datastructures.WWWAuthenticate.nonce" title="Permalink to this definition">¶</a></dt>
<dd><p>A server-specified data string which should be uniquely generated
each time a 401 response is made. It is recommended that this
string be base64 or hexadecimal data.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.WWWAuthenticate.opaque">
<code class="descname">opaque</code><a class="headerlink" href="#werkzeug.datastructures.WWWAuthenticate.opaque" title="Permalink to this definition">¶</a></dt>
<dd><p>A string of data, specified by the server, which should
be returned by the client unchanged in the Authorization header
of subsequent requests with URIs in the same protection space.
It is recommended that this string be base64 or hexadecimal
data.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.WWWAuthenticate.qop">
<code class="descname">qop</code><a class="headerlink" href="#werkzeug.datastructures.WWWAuthenticate.qop" title="Permalink to this definition">¶</a></dt>
<dd><p>A set of quality-of-privacy directives such as auth and
auth-int.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.WWWAuthenticate.realm">
<code class="descname">realm</code><a class="headerlink" href="#werkzeug.datastructures.WWWAuthenticate.realm" title="Permalink to this definition">¶</a></dt>
<dd><p>A string to be displayed to users so they know which
username and password to use. This string should contain at
least the name of the host performing the authentication and
might additionally indicate the collection of users who might
have access.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.WWWAuthenticate.set_basic">
<code class="descname">set_basic</code><span class="sig-paren">(</span><em>realm='authentication required'</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.WWWAuthenticate.set_basic" title="Permalink to this definition">¶</a></dt>
<dd><p>Clear the auth info and enable basic auth.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.WWWAuthenticate.set_digest">
<code class="descname">set_digest</code><span class="sig-paren">(</span><em>realm</em>, <em>nonce</em>, <em>qop=('auth'</em>, <em>)</em>, <em>opaque=None</em>, <em>algorithm=None</em>, <em>stale=False</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.WWWAuthenticate.set_digest" title="Permalink to this definition">¶</a></dt>
<dd><p>Clear the auth info and enable digest auth.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.WWWAuthenticate.stale">
<code class="descname">stale</code><a class="headerlink" href="#werkzeug.datastructures.WWWAuthenticate.stale" title="Permalink to this definition">¶</a></dt>
<dd><p>A flag, indicating that the previous request from the client
was rejected because the nonce value was stale.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.WWWAuthenticate.to_header">
<code class="descname">to_header</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.WWWAuthenticate.to_header" title="Permalink to this definition">¶</a></dt>
<dd><p>Convert the stored values into a WWW-Authenticate header.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.WWWAuthenticate.type">
<code class="descname">type</code><a class="headerlink" href="#werkzeug.datastructures.WWWAuthenticate.type" title="Permalink to this definition">¶</a></dt>
<dd><p>The type of the auth mechanism. HTTP currently specifies
<code class="docutils literal notranslate"><span class="pre">Basic</span></code> and <code class="docutils literal notranslate"><span class="pre">Digest</span></code>.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.IfRange">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">IfRange</code><span class="sig-paren">(</span><em>etag=None</em>, <em>date=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.IfRange" title="Permalink to this definition">¶</a></dt>
<dd><p>Very simple object that represents the <cite>If-Range</cite> header in parsed
form.  It will either have neither a etag or date or one of either but
never both.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.7.</span></p>
</div>
</details><dl class="attribute">
<dt id="werkzeug.datastructures.IfRange.date">
<code class="descname">date</code><em class="property"> = None</em><a class="headerlink" href="#werkzeug.datastructures.IfRange.date" title="Permalink to this definition">¶</a></dt>
<dd><p>The date in parsed format or <cite>None</cite>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.IfRange.etag">
<code class="descname">etag</code><em class="property"> = None</em><a class="headerlink" href="#werkzeug.datastructures.IfRange.etag" title="Permalink to this definition">¶</a></dt>
<dd><p>The etag parsed and unquoted.  Ranges always operate on strong
etags so the weakness information is not necessary.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.IfRange.to_header">
<code class="descname">to_header</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.IfRange.to_header" title="Permalink to this definition">¶</a></dt>
<dd><p>Converts the object back into an HTTP header.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.Range">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">Range</code><span class="sig-paren">(</span><em>units</em>, <em>ranges</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Range" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents a <code class="docutils literal notranslate"><span class="pre">Range</span></code> header. All methods only support only
bytes as the unit. Stores a list of ranges if given, but the methods
only work if only one range is provided.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Raises:</th><td class="field-body"><a class="reference external" href="https://docs.python.org/3/library/exceptions.html#ValueError" title="(in Python v3.8)"><strong>ValueError</strong></a> – If the ranges provided are invalid.</td>
</tr>
</tbody>
</table>
<details class="changelog">
<summary>Changelog</summary><div class="versionchanged">
<p><span class="versionmodified">Changed in version 0.15: </span>The ranges passed in are validated.</p>
</div>
<div class="versionadded">
<p><span class="versionmodified">New in version 0.7.</span></p>
</div>
</details><dl class="method">
<dt id="werkzeug.datastructures.Range.make_content_range">
<code class="descname">make_content_range</code><span class="sig-paren">(</span><em>length</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Range.make_content_range" title="Permalink to this definition">¶</a></dt>
<dd><p>Creates a <a class="reference internal" href="#werkzeug.datastructures.ContentRange" title="werkzeug.datastructures.ContentRange"><code class="xref py py-class docutils literal notranslate"><span class="pre">ContentRange</span></code></a> object
from the current range and given content length.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Range.range_for_length">
<code class="descname">range_for_length</code><span class="sig-paren">(</span><em>length</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Range.range_for_length" title="Permalink to this definition">¶</a></dt>
<dd><p>If the range is for bytes, the length is not None and there is
exactly one range and it is satisfiable it returns a <code class="docutils literal notranslate"><span class="pre">(start,</span> <span class="pre">stop)</span></code>
tuple, otherwise <cite>None</cite>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.Range.ranges">
<code class="descname">ranges</code><em class="property"> = None</em><a class="headerlink" href="#werkzeug.datastructures.Range.ranges" title="Permalink to this definition">¶</a></dt>
<dd><p>A list of <code class="docutils literal notranslate"><span class="pre">(begin,</span> <span class="pre">end)</span></code> tuples for the range header provided.
The ranges are non-inclusive.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Range.to_content_range_header">
<code class="descname">to_content_range_header</code><span class="sig-paren">(</span><em>length</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Range.to_content_range_header" title="Permalink to this definition">¶</a></dt>
<dd><p>Converts the object into <cite>Content-Range</cite> HTTP header,
based on given length</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.Range.to_header">
<code class="descname">to_header</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.Range.to_header" title="Permalink to this definition">¶</a></dt>
<dd><p>Converts the object back into an HTTP header.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.Range.units">
<code class="descname">units</code><em class="property"> = None</em><a class="headerlink" href="#werkzeug.datastructures.Range.units" title="Permalink to this definition">¶</a></dt>
<dd><p>The units of this range.  Usually “bytes”.</p>
</dd></dl>

</dd></dl>

<dl class="class">
<dt id="werkzeug.datastructures.ContentRange">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">ContentRange</code><span class="sig-paren">(</span><em>units</em>, <em>start</em>, <em>stop</em>, <em>length=None</em>, <em>on_update=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.ContentRange" title="Permalink to this definition">¶</a></dt>
<dd><p>Represents the content range header.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.7.</span></p>
</div>
</details><dl class="attribute">
<dt id="werkzeug.datastructures.ContentRange.length">
<code class="descname">length</code><a class="headerlink" href="#werkzeug.datastructures.ContentRange.length" title="Permalink to this definition">¶</a></dt>
<dd><p>The length of the range or <cite>None</cite>.</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.ContentRange.set">
<code class="descname">set</code><span class="sig-paren">(</span><em>start</em>, <em>stop</em>, <em>length=None</em>, <em>units='bytes'</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.ContentRange.set" title="Permalink to this definition">¶</a></dt>
<dd><p>Simple method to update the ranges.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.ContentRange.start">
<code class="descname">start</code><a class="headerlink" href="#werkzeug.datastructures.ContentRange.start" title="Permalink to this definition">¶</a></dt>
<dd><p>The start point of the range or <cite>None</cite>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.ContentRange.stop">
<code class="descname">stop</code><a class="headerlink" href="#werkzeug.datastructures.ContentRange.stop" title="Permalink to this definition">¶</a></dt>
<dd><p>The stop point of the range (non-inclusive) or <cite>None</cite>.  Can only be
<cite>None</cite> if also start is <cite>None</cite>.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.ContentRange.units">
<code class="descname">units</code><a class="headerlink" href="#werkzeug.datastructures.ContentRange.units" title="Permalink to this definition">¶</a></dt>
<dd><p>The units to use, usually “bytes”</p>
</dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.ContentRange.unset">
<code class="descname">unset</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.ContentRange.unset" title="Permalink to this definition">¶</a></dt>
<dd><p>Sets the units to <cite>None</cite> which indicates that the header should
no longer be used.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="others">
<h2>Others<a class="headerlink" href="#others" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="werkzeug.datastructures.FileStorage">
<em class="property">class </em><code class="descclassname">werkzeug.datastructures.</code><code class="descname">FileStorage</code><span class="sig-paren">(</span><em>stream=None</em>, <em>filename=None</em>, <em>name=None</em>, <em>content_type=None</em>, <em>content_length=None</em>, <em>headers=None</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.FileStorage" title="Permalink to this definition">¶</a></dt>
<dd><p>The <a class="reference internal" href="#werkzeug.datastructures.FileStorage" title="werkzeug.datastructures.FileStorage"><code class="xref py py-class docutils literal notranslate"><span class="pre">FileStorage</span></code></a> class is a thin wrapper over incoming files.
It is used by the request object to represent uploaded files.  All the
attributes of the wrapper stream are proxied by the file storage so
it’s possible to do <code class="docutils literal notranslate"><span class="pre">storage.read()</span></code> instead of the long form
<code class="docutils literal notranslate"><span class="pre">storage.stream.read()</span></code>.</p>
<dl class="attribute">
<dt id="werkzeug.datastructures.FileStorage.stream">
<code class="descname">stream</code><a class="headerlink" href="#werkzeug.datastructures.FileStorage.stream" title="Permalink to this definition">¶</a></dt>
<dd><p>The input stream for the uploaded file.  This usually points to an
open temporary file.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.FileStorage.filename">
<code class="descname">filename</code><a class="headerlink" href="#werkzeug.datastructures.FileStorage.filename" title="Permalink to this definition">¶</a></dt>
<dd><p>The filename of the file on the client.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.FileStorage.name">
<code class="descname">name</code><a class="headerlink" href="#werkzeug.datastructures.FileStorage.name" title="Permalink to this definition">¶</a></dt>
<dd><p>The name of the form field.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.FileStorage.headers">
<code class="descname">headers</code><a class="headerlink" href="#werkzeug.datastructures.FileStorage.headers" title="Permalink to this definition">¶</a></dt>
<dd><p>The multipart headers as <a class="reference internal" href="#werkzeug.datastructures.Headers" title="werkzeug.datastructures.Headers"><code class="xref py py-class docutils literal notranslate"><span class="pre">Headers</span></code></a> object.  This usually contains
irrelevant information but in combination with custom multipart requests
the raw headers might be interesting.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.6.</span></p>
</div>
</details></dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.FileStorage.close">
<code class="descname">close</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.FileStorage.close" title="Permalink to this definition">¶</a></dt>
<dd><p>Close the underlying file if possible.</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.FileStorage.content_length">
<code class="descname">content_length</code><a class="headerlink" href="#werkzeug.datastructures.FileStorage.content_length" title="Permalink to this definition">¶</a></dt>
<dd><p>The content-length sent in the header.  Usually not available</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.FileStorage.content_type">
<code class="descname">content_type</code><a class="headerlink" href="#werkzeug.datastructures.FileStorage.content_type" title="Permalink to this definition">¶</a></dt>
<dd><p>The content-type sent in the header.  Usually not available</p>
</dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.FileStorage.mimetype">
<code class="descname">mimetype</code><a class="headerlink" href="#werkzeug.datastructures.FileStorage.mimetype" title="Permalink to this definition">¶</a></dt>
<dd><p>Like <a class="reference internal" href="#werkzeug.datastructures.FileStorage.content_type" title="werkzeug.datastructures.FileStorage.content_type"><code class="xref py py-attr docutils literal notranslate"><span class="pre">content_type</span></code></a>, but without parameters (eg, without
charset, type etc.) and always lowercase.  For example if the content
type is <code class="docutils literal notranslate"><span class="pre">text/HTML;</span> <span class="pre">charset=utf-8</span></code> the mimetype would be
<code class="docutils literal notranslate"><span class="pre">'text/html'</span></code>.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.7.</span></p>
</div>
</details></dd></dl>

<dl class="attribute">
<dt id="werkzeug.datastructures.FileStorage.mimetype_params">
<code class="descname">mimetype_params</code><a class="headerlink" href="#werkzeug.datastructures.FileStorage.mimetype_params" title="Permalink to this definition">¶</a></dt>
<dd><p>The mimetype parameters as dict.  For example if the content
type is <code class="docutils literal notranslate"><span class="pre">text/html;</span> <span class="pre">charset=utf-8</span></code> the params would be
<code class="docutils literal notranslate"><span class="pre">{'charset':</span> <span class="pre">'utf-8'}</span></code>.</p>
<details class="changelog">
<summary>Changelog</summary><div class="versionadded">
<p><span class="versionmodified">New in version 0.7.</span></p>
</div>
</details></dd></dl>

<dl class="method">
<dt id="werkzeug.datastructures.FileStorage.save">
<code class="descname">save</code><span class="sig-paren">(</span><em>dst</em>, <em>buffer_size=16384</em><span class="sig-paren">)</span><a class="headerlink" href="#werkzeug.datastructures.FileStorage.save" title="Permalink to this definition">¶</a></dt>
<dd><p>Save the file to a destination path or file object.  If the
destination is a file object you have to close it yourself after the
call.  The buffer size is the number of bytes held in memory during
the copy process.  It defaults to 16KB.</p>
<p>For secure file saving also have a look at <code class="xref py py-func docutils literal notranslate"><span class="pre">secure_filename()</span></code>.</p>
<table class="docutils field-list" frame="void" rules="none">
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>dst</strong> – a filename, <a class="reference external" href="https://docs.python.org/3/library/os.html#os.PathLike" title="(in Python v3.8)"><code class="xref py py-class docutils literal notranslate"><span class="pre">os.PathLike</span></code></a>, or open file
object to write to.</li>
<li><strong>buffer_size</strong> – Passed as the <code class="docutils literal notranslate"><span class="pre">length</span></code> parameter of
<a class="reference external" href="https://docs.python.org/3/library/shutil.html#shutil.copyfileobj" title="(in Python v3.8)"><code class="xref py py-func docutils literal notranslate"><span class="pre">shutil.copyfileobj()</span></code></a>.</li>
</ul>
</td>
</tr>
</tbody>
</table>
<div class="versionchanged">
<p><span class="versionmodified">Changed in version 1.0: </span>Supports <a class="reference external" href="https://docs.python.org/3/library/pathlib.html#module-pathlib" title="(in Python v3.8)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">pathlib</span></code></a>.</p>
</div>
</dd></dl>

</dd></dl>

</div>
</div>


          </div>
        </div>
      </div>
  <span id="sidebar-top"></span>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  
    
            <p class="logo"><a href="../index.html">
              <img class="logo" src="../_static/werkzeug.png" alt="Logo"/>
            </a></p>
  

  <h3>Contents</h3>
  <ul>
<li><a class="reference internal" href="#">Data Structures</a><ul>
<li><a class="reference internal" href="#general-purpose">General Purpose</a></li>
<li><a class="reference internal" href="#http-related">HTTP Related</a></li>
<li><a class="reference internal" href="#others">Others</a></li>
</ul>
</li>
</ul>
<h3>Navigation</h3>
<ul>
  <li><a href="../index.html">Overview</a>
    <ul>
          <li>Previous: <a href="../http/index.html" title="previous chapter">HTTP Utilities</a>
          <li>Next: <a href="../utils/index.html" title="next chapter">Utilities</a>
    </ul>
  </li>
</ul>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="https://werkzeug.palletsprojects.com/en/1.0.x/search/" method="get">
      <input type="text" name="q" />
      <input type="submit" value="Go" />
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
    </div>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
  
    <div class="footer" role="contentinfo">
        &#169; Copyright 2007 Pallets.
      Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.8.5.
    </div>
    <script>
      if (typeof READTHEDOCS_DATA !== 'undefined') {
        if (!READTHEDOCS_DATA.features) {
          READTHEDOCS_DATA.features = {};
        }
        READTHEDOCS_DATA.features.docsearch_disabled = true;
      }
    </script>

  </body>

<!-- Mirrored from werkzeug.palletsprojects.com/en/1.0.x/datastructures/ by HTTrack Website Copier/3.x [XR&CO'2014], Tue, 15 Sep 2020 06:37:09 GMT -->
</html>